﻿
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GameVLTK
{
    public class PlaneMotionModule
    {
        //Cho biết đang playing hay không
        protected bool _playing;

        //Mỗi lần di chuyển sẽ + với _vx, _vy
        protected float _vx;
        protected float _vy;

        public PlaneMotionModule()
        {
            this._playing = true;
            this._vx = this._vy = 0f;
        }

        public PlaneMotionModule(float vx, float vy)
        {
            this._playing = true;
            this._vx = vx;
            this._vy = vy;
        }

        public virtual void OnMotion(Player character, GameTime gameTime)
        {
            Vector2 v = character.TopLeft;
            v.X += this._vx;
            v.Y += this._vy;
            character.TopLeft = v;
        }

        public virtual void Pause()
        {
        }

        public virtual void Play()
        {
        }

        public virtual void Play(float fTime)
        {
        }

        public virtual void Stop()
        {
            this._vx = this._vy = 0f;
        }

        public virtual bool IsMoving
        {
            get
            {
                return false;
            }
        }

        public bool IsPlaying
        {
            get
            {
                return this._playing;
            }
            set
            {
                this._playing = value;
                if (!value)
                {
                    this.Stop();
                }
            }
        }

        public Vector2 Velocity
        {
            get
            {
                return new Vector2(this._vx, this._vy);
            }
            set
            {
                this._vx = value.X;
                this._vy = value.Y;
            }
        }

        public float Vx
        {
            get
            {
                return this._vx;
            }
            set
            {
                this._vx = value;
            }
        }

        public float Vy
        {
            get
            {
                return this._vy;
            }
            set
            {
                this._vy = value;
            }
        }
    }
}

